<template>
    <iframe :src="urlPath" class="iframe" ref="iframe" v-loading.fullscreen.lock="fullscreenLoading"/>
</template>

<script>
export default {
    name: 'myiframe',
    components: {},
    props: ['urlPath'],
    data() {
        return {
            fullscreenLoading: false
        }
    },
    created() {
        this.fullscreenLoading = true
    },
    mounted() {
        this.iframeInit()
        window.onresize = () => {
            this.iframeInit()
        }
    },
    methods: {
        iframeInit() {
            const iframe = this.$refs.iframe
            const clientHeight = document.documentElement.clientHeight - 90
            iframe.style.height = `${clientHeight}px`
            if (iframe.attachEvent) {
                iframe.attachEvent('onload', () => {
                    this.fullscreenLoading = false
                })
            } else {
                iframe.onload = () => {
                    this.fullscreenLoading = false
                }
            }
        },
        getUrlPath: function() {
            let url = window.location.href
            url = url.replace('/iframe', '')
            return url
        }
    }
}
</script>
